<template>
  <base-breadcrumb>
    <searchData :search-data="searchArr" @search="search" />
    <a-card>
      <!-- <title-name title="现场管理列表" /> -->
      <list-table
        ref="table"
        :columns="columns"
        :request="loadData"
        :exportConfig="{ use: true,select: '现场管理',all: '现场管理'}"
        :exportPermission="{select: 'mm_043_exp_05',all: 'mm_043_expall_06'}"
      >
        <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
        <template slot="prefix" slot-scope="ref">
          <a-button type="primary" icon="plus" @click="add({},'add')" v-btn-permission="'mm_043_add_01'">
            新增
          </a-button>
        </template>
        <template slot="actions" slot-scope="text, record">
          <MoreButton>
            <a @click="add(record,'look')" v-btn-permission="'mm_043_loo_04'">查看</a>
            <a @click="add(record,'edit')" v-btn-permission="'mm_043_edi_02'">编辑</a>
            <a @click="del(record,'look')" v-btn-permission="'mm_043_del_03'">删除</a>
          </MoreButton>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>
<script>
import { del, findListByMain, findListCount } from '@/api/material/use/scene'
import SelectSubCompany from '@/components/Select/SelectSubCompany'
import SelectProject from '@/components/Select/SelectProject'
import OrgTreeSelect from '@/components/OrgTreeSelect'
import { selectOption } from '@/api/material/goods/goods'
import BSelect from '@/components/BComponents/BSelect'

export default {
  name: 'index',
  components: {},
  data() {
    return {
      searchArr: [
      {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
        // {
        //   name: '所属分公司',
        //   valueKey: 'branchComId',
        //   type: SelectSubCompany
        // },
        // {
        //   name: '项目名称',
        //   type: SelectProject,
        //   keyValue: 'branchComId',
        //   valueKey: 'projectId'
        // },
        {
          name: '管理单编号',
          value: 'code',
          type: 'input'
        },
        {
          name: '类型',
          valueKey: 'typesLabelId',
          type: BSelect,
          request: () => selectOption({ type: 35 })
        },
        {
          name: '分包商名称',
          value: 'subContractName',
          type: 'input'
        },
        {
          name: '创建人',
          value: 'creatorName',
          type: 'input'
        },
        {
          name: '创建时间',
          value: 'createTime',
          type: 'timeRangeFormat'
        }
      ],
      columns: [
        { title: '序号', width: '65px', scopedSlots: { customRender: 'serial' } },
        { title: '所属分公司', dataIndex: 'branchComName', width: 120 },
        { title: '管理单编号', dataIndex: 'code', width: 120 },
        { title: '项目名称', dataIndex: 'projectName' },
        { title: '类型', dataIndex: 'typesLabelName', width: 100 },
        { title: '分包商名称', dataIndex: 'subContractName', width: 140 },
        { title: '创建人', dataIndex: 'creatorName', width: 160 },
        { title: '创建时间', dataIndex: 'createTime', width: 160 },
        {
          title: '操作',
          dataIndex: 'actions',
          width: 150,
          fixed: 'right',
          scopedSlots: { customRender: 'actions' }
        }
      ],
      searchParams: {},
      loadData: p => {
        let q = Object.assign(p, { query: this.searchParams })
        // findListCount({}, q).then(res => {
        //   if (res.code === this.SUCCESS_CODE) {
        //
        //   }
        // })
        return findListByMain({}, q)
      }
    }
  },
  computed: {},
  watch: {},
  created() {
  },
  methods: {
    search(val) {
      this.searchParams = val || {}
      this.$refs.table.refresh()
    },
    del(row) {
      this.$delList3(del, () => {
        this.search()
      }, { id: row.id })
    },
    add(row, type) {
      this.$nav('/material/use/sceneAdd', { id: row.id, pageType: type })
    }
  }
}
</script>
